package com.crealth.msg;

import java.io.UnsupportedEncodingException;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSONObject;


public class NetMessageData implements Cloneable {
	private static final Logger errorLog = Logger.getLogger("error_log");
	
	public static final int Net_Stop_All = 400;
	public static final int Net_ReConnect = 401;  //  客户端重连
	public static final int Net_RS_VOICECODECS = 402;  //  语音编码 重新设置
	public static final int Net_HIDE_CONSUMER_INFO = 403;  //  客户端 隐藏 客户资料
	public static final int Net_MODIFY_SIP = 500;  //  sip 账号更新
	public static final int Net_Heart_Beat = 600;
	public static final int Net_REV_LOGIN = 601;
	public static final int Net_REV_LOGOUT = 602;
	public static final int Net_Obtain_Version = 603;
	public static final int Net_Commit_Mobi_Attribute = 604;  // 提交手机归属地
	public static final int Net_Obtain_Company = 605;  // 获取公司信息
	public static final int Net_Obtain_Leaders = 606;
	public static final int Net_Obtain_Underling = 607;  //  获取 下属
	public static final int Net_Obtain_All_Team = 608;  //  获取 所有团队
	public static final int Net_Import_Clientele_Detail = 609;  // 导入详细的客户信息
	public static final int Net_Obtain_Client = 610;
	public static final int Net_Add_Client = 611;
	public static final int Net_Begin_Cdr = 612;
	public static final int Net_End_Cdr = 613;
	public static final int Net_Call_Phone = 614;
	public static final int Net_Add_Branch = 615;  // 新增分公司 或者 部门
	public static final int Net_Save_All_Company = 616;  // 保存 所有公司 或者 部门
	public static final int Net_Del_Branch = 617;  // 删除 公司 或者 部门
	// 提交 意向客户
	public static final int Net_Commit_VisitInfo = 618;
	// 获取 意向客户列表
	public static final int Net_Obtain_VisitInfo = 619;
	//  新增用户
	public static final int Net_Add_Staff = 620;
	//  修改密码
	public static final int Net_Modify_Pwd = 621;
	public static final int Net_Add_Company = 622;
	public static final int Net_Add_Team = 623;
	public static final int Net_Save_All_Team = 624;  // 保存所有 团队信息
	public static final int Net_Sync_CliDetailInfo = 625;  //  同步服务器端的数据
	
	// 开发客户  提交客户详细信息
	public static final int Net_Commit_CliDetailInfo = 626;
	//  获取 客户跟单
	public static final int Net_Obtain_CliDetailInfos = 627;
	//  修改  客户资料
	public static final int Net_Modify_CliDetailInfos = 628;
	public static final int Net_Upload_Purpose_Clients = 629;  //  导入 Execl 意向客户列表
	//  查询 客户资料
	public static final int Net_Search_Client = 630;
	// 提交领导批示
	public static final int Net_Commit_LeaderGuide = 631;
	//  领导修改了  批示
	public static final int Net_Modify_LeaderGuide = 632;
	public static final int Net_Submit_Consumer_Noti = 633;  // 提交了 约谈客户
	public static final int Net_Save_Next_Followup = 634;  // 保存 下次跟进结点
	public static final int Net_Del_Next_Followup = 635;  // 删除  下次跟进结点
	
	public static final int Net_Upload_Record = 680;  //  上传录音文件
	public static final int Net_Search_Record_Cdr = 681;  //  检查录音
	public static final int Net_Check_Day_KPI = 685;  //  查看 日KPI
	public static final int Net_Check_Month_KPI = 686;  //  查看 月 KPI
	public static final int Net_Check_Week_KPI = 687;  //  查看 周 KPI
	public static final int Net_Dispatch_Purpose = 690;  //  分配意向客户
	public static final int Net_Copy_Purpose = 691;  //  copy 意向客户
	public static final int Net_Modify_Staff_Info = 692;  //  修改 员工信息
	public static final int Net_Del_LoanContract = 700;  // 合同作废  删除
	public static final int Net_Obtain_MeetTalk = 701;  //  获取 公司约谈的客户
	public static final int Net_Add_LoanContract = 702;  //  新增 贷款合同
	public static final int Net_Obtain_LoanContract = 703;  // 获取贷款合同
	public static final int Net_SendBack_LoanContract = 704;  // 回退  意向客户约谈
	public static final int Net_Modify_LoanContract = 705;  // 修改 合同
	public static final int Net_Signed_LoanContract = 706;  // 已签 合同
	public static final int Net_All_LoanContract = 707;  // 获取  所有的 合同
	
	public static final int Net_All_ConsumerProduct = 708;  // 获取  所有的 产品
	public static final int Net_Save_ConsumerProduct = 709;  // 保存 产品
	public static final int Net_Add_ConsumerProduct = 710;  // 新增 产品
	public static final int Net_Accept_ConsumerProduct = 712;  // 按揭经理接受
	public static final int Net_Modify_DiYa_Follow = 713;  // 抵押
	public static final int Net_Obtain_DiYa_Follow = 714;  // 抵押  详情	
	public static final int Net_Save_WeekPlan = 716;  // 保存周计划
	
	public static final int Net_Confirm_Brokerage = 718;  // 确认 佣金
	public static final int Net_Confirm_Earnest = 719;  // 确认 定金的信息
	public static final int Net_Save_Back_Earnest = 720;  // 保存 退定金的信息
	public static final int Net_Obtain_Back_Earnest = 721;  // 获取 退定金的信息
	public static final int Net_Check_Back_Earnest = 722;  // 分公司 经理  核实 退定金
	public static final int Net_Finance_Back_Earnest = 723;  // 财务   退定金
	public static final int Net_Confirm_Back_Earnest = 724;  // 客服  核实
	public static final int Net_Cancel_Back_Earnest = 725;  // 撤销 退款	
	public static final int Net_Upload_ContractFile = 730;  //  上传合同文件  pdf
	
	public static final int Net_Team_Month_Plan = 735;  // 月计划 开启 /结束
	public static final int Net_Team_Week_Plan = 736;  // 周计划 开启 /结束
	public static final int Net_Obtain_Month_Plan = 737;  // 获取月计划
	public static final int Net_Obtain_Week_Plan = 738;  // 获取周计划 
	public static final int Net_Obtain_Plan = 739;  // 获取周计划 、月计划
	
	public static final int Net_Save_BankChannel = 740;  // 保存银行 渠道
	public static final int Net_Obtain_BankChannel = 741;  // 获取银行 渠道
	public static final int Net_Save_LoanAmountCalculated = 742;  // 保存 贷款金额测算
	public static final int Net_Obtain_LoanAmountCalculated = 743;  // 获取 贷款金额测算
	public static final int Net_Save_BankSpecialLimit = 744;  // 保存银行  特殊的限制
	public static final int Net_Obtain_BankSpecialLimit = 745;  // 获取银行 特殊的限制
	
	public static final int Net_Obtain_PRODUCT_KNOWLEDGE = 750;   // 获取产品知识
	public static final int Net_Save_Credit_KNOWLEDGE = 751;   // 保存 信用贷款知识
	public static final int Net_Save_Pledget_KNOWLEDGE = 752;   // 保存 抵押贷款知识
	public static final int Net_Del_KNOWLEDGE = 753;  // 删除   产品知识
	
	public static final int Net_Save_Work_Diary = 756;   // 保存 团队工作日志
	public static final int Net_Obtain_Work_Diary = 757;   // 获取  团队工作日志
	public static final int Net_Del_Self_Client = 758;   // 删除 自有客户
	public static final int Net_Del_Team = 759;  // 删除 团队
	
	public static final int Net_Import_GroupCall_Mobi = 760;  // 上传 群呼号码
	public static final int Net_Check_Already_Call = 761;  // 	
	public static final int Net_Obtain_Init_Sip = 762;  // 获取 sip 设置
	public static final int Net_Modify_Init_Sip = 763;  // 重新设置 sip 账号
	public static final int Net_Reset_User_Pwd = 764;  // 重置密码
	
	public static final int Net_Obtain_CityDistrict = 770;  // 城市区划
	public static final int Net_Modify_CityDistrict = 771;  // 修改 城市区划
	public static final int Net_Del_CityDistrict = 772;  // 删除 城市区划
	public static final int Net_Obtain_LendingAgency = 773;  // 贷款机构
	public static final int Net_Modify_LendingAgency = 774;  // 修改   贷款机构
	public static final int Net_Del_LendingAgency = 775;  // 删除   贷款机构
	
	public static final int Net_Import_Consumer = 780;  // 导入意向客户
	public static final int Net_Obtain_PhoneNum = 781;  // 电话号码 数量
	public static final int Net_Condition_Search_Clientele = 782;  // 条件查找 客户信息
	public static final int Net_Confirm_Pwd = 783;  // 验证密码
	public static final int Net_Agree_ChangePC = 784;  // 同意更改PC
	public static final int Net_REV_LOGIN_Noti = 785;  //  登录通知
	public static final int Net_Delete_Purpose = 786;  //  删除意向客户
	
	public static final int Net_Add_Staff_Noti = 790;  //  新增用户   通知
	public static final int Net_Save_CreditReport = 791;  // 保存 征信报告
	public static final int Net_Upload_CreditReportPic = 792;  // 上传 征信报告的图片
	public static final int Net_Upload_CreditReportFile = 793;  // 上传 征信报告
	public static final int Net_Search_CreditReport = 794;  // 查询   征信报告
	public static final int Net_Upload_StaffInfo = 795;  // 上传  员工文件
	public static final int Net_Send_XiBao = 796;  // 发喜报
	public static final int Net_XiBao_Noti = 797;  // 收到喜报通知
	public static final int Net_Delete_Product = 798;   //  删除产品
	
	public static final int Net_Add_EventRemind = 801;  // 新增 时间提醒
	public static final int Net_Obtain_ER = 802;  //  获取  事件提醒列表
	public static final int Net_Del_ALL_DETAIL_Client = 803;   // 删除 自有客户
	
	private int msgBodyLen;
	private int msgCmd;
	private String msgBody;
	private JSONObject revDataMsgJson;
	private int userID;
	
	public NetMessageData() {
		userID = 0;
	}
	
	public NetMessageData(int bodyLen, byte[] body) throws UnsupportedEncodingException {
		msgBodyLen = bodyLen;
		msgBody = new String(body, "UTF-8");
		userID = 0;
		
		revDataMsgJson = JSONObject.parseObject(msgBody);
		if (revDataMsgJson == null) {
			errorLog.error("not right json format: " + msgBody);
			return;
		}
		
		String strCmd = revDataMsgJson.getString("Cmd");
		if (strCmd != null && strCmd.length() > 0) {
			msgCmd = Integer.parseInt(strCmd);
		}
	}
	
	public NetMessageData(int bodyLen, int cmd, byte[] body) {
		msgBodyLen = bodyLen;
		msgCmd = cmd;
		msgBody = new String(body);
	}
	
	public int getMsgBodyLen() {
		return msgBodyLen;
	}
	public void setMsgBodyLen(int msgBodyLen) {
		this.msgBodyLen = msgBodyLen;
	}
	public int getMsgCmd() {
		return msgCmd;
	}
	public void setMsgCmd(int msgCmd) {
		this.msgCmd = msgCmd;
	}
	public String getMsgBody() {
		return msgBody;
	}
	public void setMsgBody(String msgBody) {
		this.msgBody = msgBody;
	}
	public JSONObject getRevDataMsgJson() {
		return revDataMsgJson;
	}
	public void setRevDataMsgJson(JSONObject revDataMsgJson) {
		this.revDataMsgJson = revDataMsgJson;
	}

	public int getUserID() {
		return userID;
	}
	public void setUserID(int userID) {
		this.userID = userID;
	}
	
	@Override  
    public NetMessageData clone() {
		try {
			return (NetMessageData)super.clone();
		}
		catch (CloneNotSupportedException e) {
			errorLog.error("NetMessageData clone error ", e);
			return null;
		}          
    }
	
}
